package lyj.springcloud.controller;

import com.lyj.springcloud.entities.CommonResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

/**
 * 测试调用服务提供者，当提供者异常降级后，消费者什么情况
 */
@RestController
public class InvokeProviderController {


    public static final String SERVICE_URL = "http://nacos-payment-provider";

    @Resource
    private RestTemplate restTemplate;

// -----------------------Ribbon 调用--------------------------------

    @GetMapping("/consumer/ribbon/invoke/{id}")
    public CommonResult testRibbonInvoke(String id) {
        return restTemplate.getForObject(SERVICE_URL + "/provider/sentinel/" + id, CommonResult.class );
    }
}
